#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<string.h>
#include<ctype.h>

int count_ele(char* p, int len, char ch) 
{

    if (ch >= 97)
        ch = toupper(ch);
    int count = 0;
    int i = 0;
    if (ch >= 65 && ch <= 91) 
    {

        for (i = 0; i < len; i++) 
        {
            if (p[i] == ch || p[i] == ch + 32)
                count++;
        }
    }
    else 
    {
        for (i = 0; i < len; i++) 
        {
            if (p[i] == ch)
                count++;
        }
    }

    return count;
}
int main() 
{
    char arr[1000] = { 0 };
    gets(arr);
    char ch = 0;
    scanf("%c", &ch);
    int len = strlen(arr);
    int ret = count_ele(arr, len, ch);
    printf("%d", ret);
}